package com.per.mybootall.service.impl;

import com.per.mybootall.service.LogoutInter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;

@Service
public class Logoutimpl implements LogoutInter {
    @Autowired
    private RedisTemplate redisTemplate;
    private static String msg="";

    /*true====>>>>跳转到登录页，false=====>>>>不跳转*/
    @Override
    public String out(String roottoken, String whoareroot){
        String rootTokens=roottoken.substring(1,roottoken.length()-1);
        String who=whoareroot.substring(1,whoareroot.length()-1);
       String wh= (String)redisTemplate.opsForValue().get(who);
        System.out.println("======>>>>>>"+rootTokens+","+wh);
        if(rootTokens.equals(wh)){
            System.out.println("身份验证通过");
            if(redisTemplate.delete(who)){
                return msg="success";
            }
            System.out.println("kkkkkkkkk");
            return msg="error";
        }
        System.out.println("error");
        return msg="error";
    }

}
